package com.example.zkfx.fg

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.base.mvvm.BaseViewFragment
import com.example.zkfx.R
import com.example.zkfx.ScoreAdapter
import com.example.zkfx.databinding.FragmentAllBinding
import com.example.zkfx.room.AppDbUtils


class AllFragment : BaseViewFragment<FragmentAllBinding>() {
    lateinit var scoreAdapter: ScoreAdapter
    override fun initView() {
        scoreAdapter = ScoreAdapter()
        binding.rv.adapter = scoreAdapter
        binding.rv.layoutManager = LinearLayoutManager(context)


        queryAll()

    }
    //让activity可以调用
    public fun queryAll() {
        val queryAll = AppDbUtils.getDb().getDao().queryAll()
        scoreAdapter.data.clear()
        scoreAdapter.data.addAll(queryAll)
        scoreAdapter.notifyDataSetChanged()
    }

    override fun initData() {

    }

    override fun getLayout(): Int =R.layout.fragment_all

    override fun onResume() {
        super.onResume()
        queryAll()
    }

}